#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <numeric>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define foR(i1,st,ed) for(int i1 = st , j1 = ed ; i1 < j1 ; ++i1 )
#define fo(i1,ed) foR( i1 , 0 , ed )
#define foE(i1,st,ed) foR( i1, st, ed+1 )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line puts("")

inline void wait(double seconds) {
    double endtime = clock() + (seconds * CLOCKS_PER_SEC);
    while (clock() < endtime) {
        ;
    }
}
template<class T>
inline T fastIn() {
    register char c=0;
    register T a=0;
    bool neg=false;
    while(c<33)c=getchar();
    while(c>33) {
        if(c=='-') {
            neg=true;
        } else {
            a= (a*10)+(c-'0');
        }
        c=getchar();
    }
    return neg?-a:a;
}
//----------------------------------------------------------------------------------------------
//min-cost max flow cut [ACube]
//CF round 147 E-build string

//DEFINE MAXIMUM NODE HERE
const int MXN = (1000<<1)+10;
//DEFINE LARGE VALUE
const int INF = (int)1023456789;
struct MCF {
    int e, maxflow, mincost;
    int pre[MXN], cost[MXN], pv[MXN], head[MXN];
    bool vis[MXN];
    queue<int>q;
    struct edge {
        int c, w, v, next;
        edge() {
            c=w=v=next=0;
        }
        edge(int _c, int _v, int _w, int _next) :
            c(_c), v(_v), w(_w), next(_next) {
        }
    } E[(int)1e6];

    void init() {
        SET(head, -1);
        e = 0;
    }
    int MCMF(int s, int t) {
        int mi, i;
        maxflow = mincost = 0;
        while (!q.empty()) q.pop();
        while (true) {
            SET(pv, -1);
            SET(cost, -1);
            SET(vis, 0);
            cost[s] = 0;
            q.push(s);
            while (!q.empty()) {
                int u = q.front();
                q.pop();
                vis[u] = 0;
                for (i = head[u]; i != -1; i = E[i].next) {
                    int v = E[i].v;
                    if (E[i].c && cost[v] < cost[u] + E[i].w) {
                        cost[v] = cost[u] + E[i].w;
                        if (!vis[v]) {
                            vis[v] = 1;
                            q.push(v);
                        }
                        pre[v] = i;
                        pv[v] = u;
                    }
                }
            }
            if (pv[t] == -1) break;
            mi = INF;
            for (i = t; i != s; i = pv[i]) {
                mi = min(mi, E[ pre[i] ].c);
            }
            for (i = t; i != s; i = pv[i]) {
                E[ pre[i] ].c -= mi;
                E[ pre[i]^1 ].c += mi;
            }
            maxflow += mi;
            mincost += cost[t] * mi;
        }
        return mincost;
    }
    inline void insert(int u,int v,int w,int c,int cc = 0) {
        E[e] = edge(c,v,w,head[u]);
        head[u] = e++;
        E[e] = edge(cc,u,-w,head[v]);
        head[v] = e++;
    }
} _mcmf;
//----------------------------------------------------------------------------------------------

int city_count;
inline void proc() {
    _mcmf.init();

    foE(i,1,city_count) {
        int profit = fastIn<int>();
        //split each city node
        _mcmf.insert(i,i+city_count,profit,1);
        _mcmf.insert(i,i+city_count,0,INF);
    }
    int edge_count=fastIn<int>();
    fo(i,edge_count) {
        int u=fastIn<int>(),v=fastIn<int>();
        //tail city1 -> head city2
        _mcmf.insert(u+city_count,v,0,INF);
    }
    int round_count=fastIn<int>();
    int src = city_count*2 +1;
    int snk = src-1;
    //source => 1 , 0 , round to play
    _mcmf.insert(src,1,0,round_count);
    int retval = _mcmf.MCMF(src,snk);
    cout<<retval<<"\n";
}
int main() {
#if defined( xerxes_pc )
    if (!freopen("in1", "r", stdin))
        puts("error opening file in "), assert(0);
#endif
    while( scanf("%d",&city_count)==1 ) {
        proc();
    }
    return 0;
}